const { merge } = require('webpack-merge');
const { net } = require('@qietuzi/node-utils');
const singleSpaDefaults = require('webpack-config-single-spa-react-ts');
module.exports = (webpackConfigEnv, argv) => {
    const host = net.getIPAdress();
    const defaultConfig = singleSpaDefaults({
        orgName: 'gf-tech',
        projectName: 'initParamsName',
        webpackConfigEnv,
        argv,
    });
    return merge(defaultConfig, {
        // modify the webpack config however you'd like to by adding to this object
        devtool: defaultConfig.mode === 'production' ? false : 'source-map',
        externals: {
            'single-spa': {
                commonjs: 'single-spa',
                commonjs2: 'single-spa',
                amd: 'single-spa',
                root: 'single-spa',
            },
            react: {
                commonjs: 'react',
                commonjs2: 'react',
                amd: 'react',
                root: 'React',
            },
            'react-dom': {
                commonjs: 'react-dom',
                commonjs2: 'react-dom',
                amd: 'react-dom',
                root: 'react-dom',
            },
            moment: {
                commonjs: 'moment',
                commonjs2: 'moment',
                amd: 'moment',
                root: 'moment',
            },
            antd: {
                commonjs: 'antd',
                commonjs2: 'antd',
                amd: 'antd',
                root: 'antd',
            },
            '@gf-tech/types': {
                commonjs: '@gf-tech/types',
                commonjs2: '@gf-tech/types',
                amd: '@gf-tech/types',
                root: '@gf-tech/types',
            },
            '@gf-tech/utils': {
                commonjs: '@gf-tech/utils',
                commonjs2: '@gf-tech/utils',
                amd: '@gf-tech/utils',
                root: '@gf-tech/utils',
            },
            '@gf-tech/antd': {
                commonjs: '@gf-tech/antd',
                commonjs2: '@gf-tech/antd',
                amd: '@gf-tech/antd',
                root: '@gf-tech/antd',
            },
            '@gf-tech/ebc': {
                commonjs: '@gf-tech/ebc',
                commonjs2: '@gf-tech/ebc',
                amd: '@gf-tech/ebc',
                root: '@gf-tech/ebc',
            },
        },
        devServer: {
            port: 30019,
            client: {
                webSocketURL: `ws://${host}:30019/ws`,
            },
        },
    });
};
